<?php

namespace app\api\controller\v1;

use app\common\controller\BaseController;
use app\common\model\Post as ModelPost;
use app\common\validate\PostValidate;

class Post extends BaseController
{
    // 发布文章
    public function create()
    {
        (new PostValidate())->goCheck('create');
        (new ModelPost())->createPost();
        return $this->showResCode('发布成功');
    }
    // 获取文章详情
    public function index($id)
    {
        // 验证文章id
        (new PostValidate())->goCheck('detail');
        $detail = (new ModelPost())->goPostDetail();
        return self::showResCode('获取成功',['detail' => $detail ]);
    }

    // 获取当前文章下的评论列表
    public function comment()
    {
        (new PostValidate())->goCheck('comment');
        $list = (new ModelPost())->getComment();
        return self::showResCode('获取成功',['list' => $list]);
    }
}
